package com.bing.utils;

import org.springframework.util.StringUtils;

import javax.xml.bind.annotation.adapters.XmlAdapter;

/**
 * Created by kaibb on 2014/11/29.
 */
public class StringDataAdapter extends XmlAdapter<String, String> {

    @Override
    public String unmarshal(String v) throws Exception {
        if (StringUtils.isEmpty(v)) {
            return null;
        }
        return v;
    }

    @Override
    public String marshal(String v) throws Exception {
        return "<![CDATA[" + v + "]]>";
    }
}
